﻿<phone:PhoneApplicationPage 
    x:Class="Social_Celebrities.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:converter="clr-namespace:Social_Celebrities"
    xmlns:LART="clr-namespace:CommonControls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>

        <converter:ConvertToCapital1 x:Key="ConvertToCapital1" />
        <converter:ConvertToCapital x:Key="ConvertToCapital" />
        <converter:RssTextTrimmer x:Key="RssTextTrimmer" />
        <converter:ImageFromRssText x:Key="ImageFromRssText"></converter:ImageFromRssText>
        <converter:AuthorsFromRssText x:Key="AuthorFromRssText"></converter:AuthorsFromRssText>
        <converter:ControlVisibility x:Key="ControlVisibility"></converter:ControlVisibility>
        <converter:ImageFromRssText1 x:Key="ImageFromRssText1"></converter:ImageFromRssText1>
        <converter:DateToString x:Key="DateToString"></converter:DateToString>

        <DataTemplate x:Key="CelebrityItemTemplate">
            <StackPanel Orientation="Horizontal" 
                       Margin="4,4" 
                        Tag="{Binding PersonID}" 
                        MouseLeftButtonUp="StackPanel_MouseLeftButtonUp">
                <toolkit:ContextMenuService.ContextMenu>
                    <toolkit:ContextMenu>
                        <toolkit:MenuItem x:Name="deletecelebrity"
                                          Tag="{Binding PersonID}"
                                          Header="Delete"
                                          Click="deletecelebrity_Click">
                        </toolkit:MenuItem>
                        <toolkit:MenuItem x:Name="editcelebrity"
                                          Tag="{Binding PersonID}"
                                          Header="Edit"
                                          Click="editcelebrity_Click">
                        </toolkit:MenuItem>
                    </toolkit:ContextMenu>
                </toolkit:ContextMenuService.ContextMenu>
                <Image x:Name="imgcelebrity"
                       Width="62"
                       Height="62"
                       Source="{Binding PersonImage}"
                       VerticalAlignment="Top"/>
                <TextBlock Text="{Binding PersonName,Converter={StaticResource ConvertToCapital}}"
                           Style="{StaticResource PhoneTextLargeStyle}"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Left"/>
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="GroupHeaderTemplate">
            <Border Background="Transparent" Padding="5">
                <Border Background="{StaticResource PhoneAccentBrush}" 
                        BorderBrush="{StaticResource PhoneAccentBrush}" 
                        BorderThickness="2" 
                        Width="62" 
                        Height="62" 
                        Margin="0,0,18,0" 
                        HorizontalAlignment="Left">
                    <TextBlock 
                        Text="{Binding Key}" 
                        Foreground="{StaticResource PhoneForegroundBrush}" 
                        FontSize="48" 
                        Padding="6" 
                        FontFamily="{StaticResource PhoneFontFamilySemiLight}" 
                        HorizontalAlignment="Left" 
                        VerticalAlignment="Center"/>
                </Border>
            </Border>
        </DataTemplate>

        <phone:JumpListItemBackgroundConverter x:Key="BackgroundConverter"/>
        <phone:JumpListItemForegroundConverter x:Key="ForegroundConverter"/>
        <Style x:Key="JumpListStyle" TargetType="phone:LongListSelector">
            <Setter Property="GridCellSize"  Value="113,113"/>
            <Setter Property="LayoutMode" Value="Grid" />
            <Setter Property="ItemTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Border Background="{Binding Converter={StaticResource BackgroundConverter}}" 
                                Width="113" 
                                Height="113" 
                                Margin="6" >
                            <TextBlock 
                                Text="{Binding Key}" 
                                FontFamily="{StaticResource PhoneFontFamilySemiBold}" 
                                FontSize="48" 
                                Padding="6" 
                                Foreground="{Binding Converter={StaticResource ForegroundConverter}}" 
                                VerticalAlignment="Center"/>
                        </Border>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="commentCountStyle" TargetType="TextBlock">
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="FontSize" Value="22"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="Width" Value="30"/>
            <Setter Property="Height" Value="44"/>
            <Setter Property="IsHitTestVisible" Value="true"/>
            <Setter Property="Margin" Value="15,5,0,0"/>
        </Style>

    </phone:PhoneApplicationPage.Resources>

    <Grid x:Name="LayoutRoot" Background="{StaticResource bipivot}">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <controls:Pivot Grid.Row="0"
            x:Name="pvtMainDetails" 
            SelectionChanged="pvtMainDetails_SelectionChanged">
            <controls:Pivot.Title>
                <StackPanel 
                    Orientation="Horizontal" 
                    Margin="0,-5,0,0" 
                    Height="55">
                    <Image Style="{StaticResource DetailPagePivotTitleImage}" 
                                    x:Name="imgTitle" Margin="0,0,5,15"
                                    MouseLeftButtonDown="imgTitle_MouseEnter"/>
                    <Image Style="{StaticResource DetailPagePivotTitleImage2}" Height="Auto" Margin="0,-5,0,10"/>
                </StackPanel>
            </controls:Pivot.Title>
            <controls:Pivot.Foreground>
                white
            </controls:Pivot.Foreground>

            <controls:PivotItem x:Name="pvtitm1" Margin="0,-2,0,0">
                <controls:PivotItem.Header>
                    <TextBlock Text="celebrities" 
                                Height="59" Margin="0,-20,0,0"
                                FontFamily="Segoe UI" 
                                FontSize="53">
                    </TextBlock>
                </controls:PivotItem.Header>
                <Grid x:Name="ContentPanel" Margin="12,5,12,0">
                    <phone:LongListSelector
                  x:Name="listCelebrities"
                  JumpListStyle="{StaticResource JumpListStyle}"
                  Background="Transparent"
                  GroupHeaderTemplate="{StaticResource GroupHeaderTemplate}"
                  ItemTemplate="{StaticResource CelebrityItemTemplate}"
                  LayoutMode="List"
                  IsGroupingEnabled="true"
                  HideEmptyGroups ="true" HorizontalAlignment="Right" Width="456"/>
                </Grid>
            </controls:PivotItem>
            <controls:PivotItem x:Name="pvtitm2">
                <controls:PivotItem.Header>
                    <TextBlock Text="news" 
                                Margin="0,-20,0,0" 
                                FontFamily="Segoe WP" 
                                FontSize="53">
                    </TextBlock>
                </controls:PivotItem.Header>
                
                <ScrollViewer Margin="12,-35,12,0" VerticalScrollBarVisibility="Auto">
                    <StackPanel Orientation="Vertical" Margin="0,-10,0,0">
                        <ListBox Name="feedListBox" 
                                 SelectionChanged="feedListBox_SelectionChanged" 
                                 HorizontalAlignment="Left" 
                                 Margin="0,5,0,0" 
                                 ScrollViewer.VerticalScrollBarVisibility="Disabled" >
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel VerticalAlignment="Top" Margin="5,2,0,0">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Name="Author" 
                                                       TextWrapping="Wrap" 
                                                       FontFamily="Segoe WP" 
                                                       FontSize="44"
                                                       FontWeight="Light"
                                                       Width="320" 
                                                       Margin="5,0,0,0" 
                                                       Text="{Binding item.Authors,Converter={StaticResource AuthorFromRssText}}"/>
                                            <Canvas Visibility="Visible" Margin="10,11.5,0,0">
                                                <Image Source="{Binding Commentcount,Converter={StaticResource ImageFromRssText1}}" 
                                                       Height="60" 
                                                       Width="60" 
                                                       MouseLeftButtonDown="Image_MouseLeftButtonDown">
                                                </Image>
                                                <TextBlock Text="{Binding Commentcount,Converter={StaticResource ConvertToCapital1}}" 
                                                           Visibility="Visible" 
                                                           Style="{StaticResource commentCountStyle}" />
                                            </Canvas>
                                        </StackPanel>
                                        <ListBox Name="ImageList" 
                                                 Margin="10,0,0,0" 
                                                 Visibility="{Binding item.Summary.Text,Converter={StaticResource ControlVisibility}}" 
                                                 ItemsSource="{Binding item.Summary.Text,Converter={StaticResource ImageFromRssText}}" 
                                                 ScrollViewer.VerticalScrollBarVisibility="Disabled">
                                            <ListBox.ItemTemplate>
                                                <DataTemplate>
                                                    <Image Source="{Binding URL}" 
                                                           ImageFailed="Image_ImageFailed" 
                                                           Stretch="Fill" 
                                                           Width="60" 
                                                           Height="80">
                                                    </Image>
                                                </DataTemplate>
                                            </ListBox.ItemTemplate>
                                            <ListBox.ItemsPanel>
                                                <ItemsPanelTemplate>
                                                    <toolkit:WrapPanel ItemWidth="60" 
                                                                       ItemHeight="80" 
                                                                       Orientation="Horizontal"/>
                                                </ItemsPanelTemplate>
                                            </ListBox.ItemsPanel>
                                        </ListBox>
                                        <TextBlock Name="feedSummary" 
                                                   FontFamily="Segoe UI" 
                                                   FontSize="21"
                                                   FontWeight="Light"
                                                   TextWrapping="Wrap" 
                                                   Margin="12,0,0,0" 
                                                   Text="{Binding item.Summary.Text, Converter={StaticResource RssTextTrimmer}}"
                                                   />

                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock  Foreground="{StaticResource PhoneSubtleBrush}" 
                                                        Margin="12,0,0,10" 
                                                        Text="Facebook"  
                                                        FontFamily="Segoe WP" 
                                                        FontSize="18"/>
                                            <TextBlock Name="feedPubDate" 
                                                       FontFamily="Segoe UI" 
                                                       FontSize="18"
                                                       FontWeight="Light"
                                                       Foreground="{StaticResource PhoneSubtleBrush}" 
                                                       Margin="12,0,0,10" 
                                                       Text="{Binding item.PublishDate.DateTime,Converter={StaticResource DateToString}}"
                                                       />
                                        </StackPanel>
                                    </StackPanel>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>

                        <ListBox x:Name="tweetList"   
                                 SelectionChanged="tweetList_SelectionChanged"  
                                 HorizontalAlignment="Left" 
                                 Margin="0,10,0,0" 
                                 VerticalAlignment="Top" 
                                 ScrollViewer.VerticalScrollBarVisibility="Disabled" >
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel VerticalAlignment="Top" Margin="10,20,0,0" >
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Name="Author" 
                                                       TextWrapping="Wrap" 
                                                       FontFamily="Segoe WP" 
                                                       FontSize="44"
                                                       FontWeight="Light"
                                                       Width="320" 
                                                       Margin="10,0,0,0" 
                                                       Text="{Binding User.Name}" />
                                            <Image Source="/Images/arrow.png" 
                                                   Width="60" 
                                                   Height="60" 
                                                   Margin="10,0,0,0" 
                                                   MouseLeftButtonDown="Image_MouseLeftButtonDown_1">
                                            </Image>
                                        </StackPanel>
                                        <TextBlock Name="feedSummary" 
                                                   FontFamily="Segoe UI" 
                                                   FontSize="21"
                                                   FontWeight="Light"
                                                   TextWrapping="Wrap" 
                                                   Margin="12,0,0,0" 
                                                   Text="{Binding Text, Converter={StaticResource RssTextTrimmer}}"/>

                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock  Foreground="{StaticResource PhoneSubtleBrush}" 
                                                        FontFamily="Segoe WP" 
                                                        FontSize="18" 
                                                        Margin="12,0,0,10" 
                                                        Text="Twitter" />
                                            <TextBlock Name="feedPubDate" 
                                                       Foreground="{StaticResource PhoneSubtleBrush}" 
                                                       FontFamily="Segoe UI"
                                                       FontWeight="Light"
                                                       FontSize="18"
                                                       Margin="12,0,0,10"
                                                       Text="{Binding CreatedDate,Converter={StaticResource DateToString}}" />
                                        </StackPanel>
                                    </StackPanel>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>

                        <ListBox x:Name="BlogList" 
                                 SelectionChanged="BlogList_SelectionChanged" 
                                 HorizontalAlignment="Left" 
                                 Margin="0,10,0,0" 
                                 VerticalAlignment="Top" 
                                 ScrollViewer.VerticalScrollBarVisibility="Disabled" >
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel VerticalAlignment="Top" Margin="10,20,0,0" >
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Name="Author" 
                                                       TextWrapping="Wrap" 
                                                       FontFamily="Segoe WP" 
                                                       FontSize="44"
                                                       FontWeight="Light"
                                                       Width="320" 
                                                       Margin="10,0,0,0" 
                                                       Text="{Binding Authors, Converter={StaticResource AuthorFromRssText}}"/>
                                            <Image Source="/Images/plusicons.png" 
                                                   x:Name="BlogComment" 
                                                   Width="60" 
                                                   Height="60" 
                                                   Margin="10,0,0,0" 
                                                   MouseLeftButtonDown="BlogComment_MouseLeftButtonDown">
                                            </Image>
                                        </StackPanel>
                                        <TextBlock Name="feedSummary" 
                                                   FontFamily="Segoe UI" 
                                                   FontSize="21"
                                                   FontWeight="Light"
                                                   TextWrapping="Wrap" 
                                                   Margin="12,0,0,0" 
                                                   Text="{Binding Summary.Text, Converter={StaticResource RssTextTrimmer}}"/>

                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock FontFamily="Segoe WP" 
                                                       FontSize="18"  
                                                       Foreground="{StaticResource PhoneSubtleBrush}" 
                                                       Margin="12,0,0,10" 
                                                       Text="Blog" />
                                            <TextBlock FontFamily="Segoe UI" 
                                                       FontSize="18"
                                                       FontWeight="Light"
                                                       Name="feedPubDate" 
                                                       Foreground="{StaticResource PhoneSubtleBrush}" 
                                                       Margin="12,0,0,10" 
                                                       Text="{Binding PublishDate.DateTime,Converter={StaticResource DateToString}}" />
                                        </StackPanel>
                                    </StackPanel>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </StackPanel>
                </ScrollViewer>
            </controls:PivotItem>
            <controls:PivotItem>
                
                <controls:PivotItem.Header>
                    <TextBlock Text="about" 
                               Margin="0,-20,0,0"
                               FontFamily="Segoe WP" 
                               FontSize="53">
                    </TextBlock>
                </controls:PivotItem.Header>
                <LART:AboutUs></LART:AboutUs>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>
    
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/feature.settings.png"
                                            Text="Accounts"
                                            Click="ApplicationBarIconButton_Click_1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar.add.rest.png"
                                            Text="Add Person"
                                            Click="ApplicationBarIconButton_Click"/>            
            <shell:ApplicationBarIconButton IconUri="Images/question.png"
                                            Text="get started"
                                            x:Name="GetStarted" Click="GetStarted_Click_1"
                                            />
            <shell:ApplicationBarIconButton IconUri="/Images/refresh.png"
                                            Text="Refresh" x:Name="reloadbtn"
                                            />
            <shell:ApplicationBar.MenuItems>               
                <shell:ApplicationBarMenuItem
                    x:Name="settings"
                    Text="Settings" Click="settings_Click"
                    />                
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>